/**
 * pharma-model - 9 janv. 2011 guillaume
 */
package org.bspv.pharma.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.bspv.pharma.common.constant.Constants;
import org.hibernate.annotations.Filters;
import org.hibernate.annotations.Filter;

/**
 * @author guillaume
 */
@Filters(
    @Filter(name="existingSupplies", condition="destructionDate is null")
)

@Entity
@Table(name = "SUPPLY")
@Inheritance(strategy = InheritanceType.JOINED)
public class Supply implements Serializable {

    /**
     * serialVersionUID.
     */
    private static final long serialVersionUID = -5825515293782487181L;

    /**
     * Identifiant de la fourniture.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    /**
     * Type de la fourniture.
     */
    @NotNull
    @ManyToOne
    private TypeOfSupply typeOfSupply;
    /**
     * Conditionnement de la fourniture.
     */
    @ManyToOne
    private Packaging packaging;
    /**
     * Livraison de cette fourniture.
     */
    @ManyToOne(cascade = { CascadeType.ALL })
    private OrderDelivery delivery;
    /**
     * Emplacement actuel de la fourniture.
     */
    @ManyToOne
    private Place place;
    /**
     * Date de début d'utilisation/sortie du stock.
     */
    private Date functionalDate;
    /**
     * Date de destruction(utilisation).
     */
    private Date destructionDate;
    /**
     * Commentaire.
     */
    @Size(max = Constants.CONSTRAINT_COMMENT_SIZE)
    private String comment;
    /**
     * Numéro de version.
     */
    @Version
    private Integer version;

    /**
     * @return the id
     */
    public final Long getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public final void setId(final Long id) {
        this.id = id;
    }

    /**
     * @return the typeOfSupply
     */
    public final TypeOfSupply getTypeOfSupply() {
        return typeOfSupply;
    }

    /**
     * @param typeOfSupply
     *            the typeOfSupply to set
     */
    public final void setTypeOfSupply(final TypeOfSupply typeOfSupply) {
        this.typeOfSupply = typeOfSupply;
    }

    /**
     * @return the packaging
     */
    public final Packaging getPackaging() {
        return packaging;
    }

    /**
     * @param packaging
     *            the packaging to set
     */
    public final void setPackaging(final Packaging packaging) {
        this.packaging = packaging;
    }

    /**
     * @return the delivery
     */
    public final OrderDelivery getDelivery() {
        return delivery;
    }

    /**
     * @param delivery
     *            the delivery to set
     */
    public final void setDelivery(final OrderDelivery delivery) {
        this.delivery = delivery;
    }

    /**
     * @return the place
     */
    public final Place getPlace() {
        return place;
    }

    /**
     * @param place
     *            the place to set
     */
    public final void setPlace(final Place place) {
        this.place = place;
    }

    /**
     * @return the functionalDate
     */
    public final Date getFunctionalDate() {
        return functionalDate;
    }

    /**
     * @param functionalDate
     *            the functionalDate to set
     */
    public final void setFunctionalDate(final Date functionalDate) {
        this.functionalDate = functionalDate;
    }

    /**
     * @return the destructionDate
     */
    public final Date getDestructionDate() {
        return destructionDate;
    }

    /**
     * @param destructionDate
     *            the destructionDate to set
     */
    public final void setDestructionDate(final Date destructionDate) {
        this.destructionDate = destructionDate;
    }

    /**
     * @return the comment
     */
    public final String getComment() {
        return comment;
    }

    /**
     * @param comment
     *            the comment to set
     */
    public final void setComment(final String comment) {
        this.comment = comment;
    }

    /**
     * @return the version
     */
    public final Integer getVersion() {
        return version;
    }

    /**
     * @param version
     *            the version to set
     */
    public final void setVersion(final Integer version) {
        this.version = version;
    }

}
